package com.example.shop.modules.manage.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.shop.modules.manage.service.IFreightAdminService;
import com.example.shop.persistence.entity.Freight;
import com.example.shop.persistence.mapper.FreightMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.LinkedList;
import java.util.List;

/**
 * <p>
 * 运费表 服务实现类
 * </p>
 *
 * @author jason
 * @since 2020-12-02
 */
@Service
public class FreightAdminServiceImpl extends ServiceImpl<FreightMapper, Freight> implements IFreightAdminService {

    @Autowired
    private FreightMapper freightMapper;

    // 批量删除
    @Override
    public int deleteFreight(String ids){
        // 先转换为字符串数组
        String[] strs = ids.split(",");
        List<Long> ints = new LinkedList<Long>();
        for(String id: strs){
            // 在转换为long 类型数组
            ints.add(Long.valueOf(id));
        }
        //批量删除
        return freightMapper.deleteBatchIds(ints);
    }
}
